package board.action;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import board.db.BoardBean;
import board.db.BoardDAO;

public class manager_Hot_Girl_BoardListAction implements Hot_Girl_Action {
	 public Hot_Girl_ActionForward execute(HttpServletRequest request,HttpServletResponse response) throws Exception{
			BoardDAO boarddao=new BoardDAO();
			List boardlist=new ArrayList();
			
		  	int page=1;
			int limit=10;
			
			if(request.getParameter("page")!=null){
				page=Integer.parseInt(request.getParameter("page"));
			}
			
			int listcount=boarddao.getListCount(); //�� ����Ʈ ���� �޾ƿ�.
			boardlist = boarddao.getBoardList(page,limit); //����Ʈ�� �޾ƿ�.
			
			//�� ������ ��.
	   		int maxpage=(int)((double)listcount/limit+0.95); //0.95�� ���ؼ� �ø� ó��.
	   		System.out.println("maxpage======"+maxpage);
	   		//���� �������� ������ ���� ������ ��(1, 11, 21 ��...)
	   		int startpage = (((int) ((double)page / 10 + 0.9)) - 1) * 10 + 1;
	   		//���� �������� ������ ������ ������ ��.(10, 20, 30 ��...)
	   		int endpage = maxpage;
	   		
	   		if (endpage>startpage+10-1) endpage=startpage+10-1;
	   		
	   		request.setAttribute("page", page);		  //���� ������ ��.
	   		request.setAttribute("maxpage", maxpage); //�ִ� ������ ��.
	   		request.setAttribute("startpage", startpage); //���� �������� ǥ���� ù ������ ��.
	   		request.setAttribute("endpage", endpage);     //���� �������� ǥ���� �� ������ ��.
			request.setAttribute("listcount",listcount); //�� ��.
			request.setAttribute("boardlist", boardlist);
			
			Hot_Girl_ActionForward forward= new Hot_Girl_ActionForward();
		   	forward.setRedirect(false);
	   		forward.setPath("../admin/manager_hot-girl.jsp");
	   		return forward;
		 }
	 }